{literal}
<script type="text/javascript">
	function clearForm(obj) {
		$(obj).find('input:[type=text]').val('');
		$(obj).find('select').val(0);
	}
</script>
{/literal}
<h1>Produkty</h1>
{if isset($filter)}{assign var=class value=colapse}{else}{assign var=class value=expand}{/if}
{mainoptions title="Filtry" class=$class}
<form method="post" >
<table cellspacing="5" cellpadding="0" border="0">
	<tr>
		<td>
			Data:
		</td>
		<td>
			<select name="interval">
				<option value="">---</option>
				
				
				<option value="0"{if $filter.interval=='0'} selected="selected"{/if}>Dziś</option>
                                <option value="1"{if $filter.interval=='1'} selected="selected"{/if}>Wczoraj</option>
                                <option value="2"{if $filter.interval=='2'} selected="selected"{/if}>Ten miesiąc</option>
                                <option value="3"{if $filter.interval=='3'} selected="selected"{/if}>Oststni miesiąc</option>
                                <option value="4"{if $filter.interval=='4'} selected="selected"{/if}>Wszystkie</option>
				
			</select>
		</td>
		
	</tr>
	
	<tr>
		<td colspan="4" align="center"><input type="submit" value="Filtruj" /><input onclick="clearForm(this.form);this.form.submit();" type="button" value="Czyść" /></td>
	</tr>
</table>
</form>
{/mainoptions}

<div id="aaa" style="width: 100%; height: 400px; float: left; margin-bottom: 40px;"></div>

<table class="uniq_click" id="uniq_click_table" style="display: none;">
	<tbody class="tbody_data">
			<tr class="tr_data">
                            {foreach from=$graph item=data key=k}
            <td>{$data}</td>
{/foreach}
</tr>
	</tbody>
</table>

<input type="hidden" value="99" id="okres" name="okres"/>
<span style="display: none;" id="min_range">{$graphMin|date_format:"%Y-%m-%d"}</span>
<span style="display: none;" id="max_range">{$graphMax|date_format:"%Y-%m-%d"}</span>
<span style="display: none;" id="date_from_year">{$graphMin|date_format:"%Y"}</span>
<span style="display: none;" id="date_from_month">{assign var=test value=$graphMin|date_format:"%m"}{math equation="x-y" x=$test y=0}</span>
<span style="display: none;" id="date_from_day">{$graphMin|date_format:"%d"}</span>
<span style="display: none;" id="grupuj_val">{$gv}</span>


<script type="text/javascript">
{literal}

	Highcharts.visualize = function(table, options) {
   
   // the data series
   options.series = [];
   var g = {/literal}{$g}{literal};
	//date from
	var date_from_year = parseFloat($('#date_from_year').html());
	var date_from_month = parseFloat($('#date_from_month').html());
	var date_from_day = parseFloat($('#date_from_day').html());
	
	var grupuj = parseFloat($('#grupuj_val').html());
	var group =  g * 3600 * 1000 * grupuj;

   var series1 = new Array();
  
   
   $('tr', document.getElementById('uniq_click_table')).each( function(i) {
      var tr = this;
      $('td', tr).each( function(j) {
		  series1[j] = parseFloat(this.innerHTML);
      });
	  
   });
	
	

	options.series = [{ 
				  name: "Kliki",
				  pointInterval: group,
				  pointStart: Date.UTC(date_from_year, date_from_month, date_from_day),
                  data: series1
               }
		  ];
	
	
//alert(options.toSource());
   
   var chart = new Highcharts.Chart(options);
	}
	$(document).ready(function() {       
   var table = document.getElementById('sells_click_table'),
   options = {
         chart: {
            renderTo: 'aaa',
            defaultSeriesType: 'spline',
			zoomType: 'x'
         },
         title: {
            text: ''
         },
          xAxis: {
         type: 'datetime',
         maxZoom: 14 * 24 * 3600000, // fourteen days
         title: {
            text: 'Data'
         }
			},
         yAxis: {
            title: {
               text: 'Ilo\u015bć'
            }
         },
         tooltip: {
         shared: true,
		 crosshairs: true
		},
		exporting: {
        enabled: true
        
		}
      };
   
                     
   Highcharts.visualize(table, options);
});
	
	

  {/literal} 
</script>
<br style="clear: both;" />
<div style="clear: both;"></div>
{mainoptions title="Lista"}
		<table cellspacing="0" cellpadding="0" border="0">
			<tr>
				<td>{tables label="ID" tid=product_table_main o=id}</td>
				<td>{tables label="Nazwa" tid=product_table_main o=name}</td>
				<td>{tables label="Kod" tid=product_table_main o=serial}</td>
                                <td>{tables label="Klików" tid=product_table_main o=count}</td>
				

			</tr>
			{foreach from=$list item=obj name=product_table_main}
			<tr>
				<td>{$obj->getId()}</td>
				<td>{$obj->getName()}</td>
				<td>{$obj->getCode()}</td>
                                <td>{$obj->getCount()}</td>
				
			</tr>
			{/foreach}
			<tr class="selAllRow">
				<td colspan="2">
					<div class="pager">
						{tables type='pagination' tid='product_table_main' all_count=$c}
						{tables type='on_page' tid='product_table_main'}
					</div>
				</td>
			</tr>
		</table>
{/mainoptions}